import Vue from 'vue'
import Router from 'vue-router'
import { constantRoutes } from '@/framework/router'
import Layout2 from '@/views/mall/homePage/index'

Vue.use(Router)
// import Layout from '@/framework/layout'

/**
 * 注意事项
 * 具体使用方法参考framework中router模块
 * 方法名不要与framework中router模块方法名重复
 */

const customRouter = [
  {
    path: '/mall/shopping',
    component: Layout2,
    children: [
      // {
      //   path: '',
      //   redirect: 'container'
      // },
      {
        path: '/mall/container',
        component: () => import('@/views/mall/homePage/container')
      },
      {
        path: '/mall/product',
        name: 'product',
        component: () => import('@/views/mall/productDetail/index')
      }

      //     {
      //       path: "/goodDetail",
      //       name: "goodDetail",
      //       component: () => import("@/views/mall/homePage/goodDetail"), // 详情页
      //     },
      //     {
      //       path: "/mall/shopcart", // 购物车页面
      //       name: "shopcart",
      //       component: () => import("@/views/mall/shopping_cart/shoppingcart"),
      //     },
      //     {
      //       path: "/payPage",
      //       name: "payPage",
      //       component: () => import("@/views/mall/shopping_cart/payPage"),
      //     },
      //     {
      //       path: "/shopcart2",
      //       name: "shopcart2",
      //       component: () => import("@/views/mall/shopping_cart2/shoppingcart"),
      //     },
      //     {
      //       path: "/binaryTree",
      //       name: "binaryTree",
      //       component: () => import("@/views/mall/binaryTree/binaryTree"),
      //     },
      // {
      //   path: "/myorder",
      //   name: "myorder",
      //   component: () => import("@/views/mall/myOrder/myOrder"),
      // },
      // {
      //   path: "/orderdetails",
      //   name: "orderdetails",
      //   component: () => import("@/views/mall/orderDetails/orderdetails"),
      // },
      //     {
      //       path: "/confirmAnOrder",
      //       name: "confirmAnOrder",
      //       component: () => import("@/views/mall/confirmAnOrder/confirmAnOrder"),
      //     },
      //     {
      //       path: "/personalCenter",
      //       name: "personalCenter",
      //       component: () => import("@/views/mall/personalCenter/personalCenter"),
      //     },
      //     {
      //       path: "/submitOrder",
      //       name: "submitOrder",
      //       component: () => import("@/views/mall/submitOrder/submitOrder"),
      //     },
      //     {
      //       path: "/mall/searchGoods", // 搜索商品页
      //       name: "searchGoods",
      //       component: () => import("@/views/mall/searchGoods/searchGoods"),
      //     },
      //     {
      //       path: "/mall/searchShops", // 搜索店铺页
      //       name: "searchShops",
      //       component: () => import("@/views/mall/searchShops/searchShops"),
      //     },
      //     {
      //       path: "/mall/profile", //个人中心
      //       name: "profile",
      //       component: () => import("@/views/mall/profile/index"),
      //       children: [
      //         {
      //           path: "/mall/profile/information", //个人资料
      //           name: "information",
      //           component: () => import("@/views/mall/profile/information"),
      //         },
      //         {
      //           path: "/mall/profile/address", //收货地址
      //           name: "address",
      //           component: () => import("@/views/mall/profile/profileAddress"),
      //         },
      //         {
      //           path: "/mall/profile/myFavorite", //我的收藏
      //           name: "myFavorite",
      //           component: () => import("@/views/mall/profile/myFavorite"),
      //           children: [
      //             {
      //               path: "/mall/profile/myFavorite/doteyCollect", //宝贝收藏
      //               name: "doteyCollect",
      //               component: () => import("@/views/mall/profile/doteyCollect"),
      //             },
      //             {
      //               path: "/mall/profile/myFavorite/shopCollect", //店铺收藏
      //               name: "shopCollect",
      //               component: () => import("@/views/mall/profile/shopCollect"),
      //             },
      //           ],
      //         },
      //       ],
      //     },
    ]
  },
  {
    path: '/mall/register',
    name: 'register',
    component: () => import('@/views/mall/register/registerPage.vue')
  },
  {
    path: '/monitorPlay/playView',
    name: 'playView',
    component: () =>
      import(
        /* webpackChunkName: "monitorPlay" */ '@/views/monitorPlay/playView'
      )
  },
  {
    path: '/monitorPlay/playDownView',
    name: 'playDownView',
    component: () =>
      import(
        /* webpackChunkName: "monitorPlay" */ '@/views/monitorPlay/playDownView'
      )
  },
  {
    path: '/monitorPlay/playGroupView',
    name: 'playGroupView',
    component: () =>
      import(
        /* webpackChunkName: "monitorPlay" */ '@/views/monitorPlay/playGroupView'
      )
  },
  {
    path: '/onlineClassroom',
    name: 'onlineClassroom',
    redirect: '/onlineClassroom/home',
    component: () =>
      import(
        /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/classroomIndex'
      ),
    children: [
      {
        path: '/onlineClassroom/home',
        name: 'classroomHome',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/classroomHome'
          )
      },
      // {
      //   path: '/onlineClassroom/contest',
      //   name: 'classroomContest',
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/classroomContest'
      //     ),
      //   meta: {
      //     topMenu: 'onlineStudy'
      //   }
      // },
      {
        path: '/onlineClassroom/course',
        name: 'classroomCourse',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/classroomCourse'
          ),
        meta: {
          topMenu: 'onlineStudy'
        }
      },
      // {
      //   path: '/onlineClassroom/other',
      //   name: 'classroomOther',
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/classroomOther'
      //     ),
      //   meta: {
      //     topMenu: 'onlineStudy'
      //   }
      // },
      {
        path: '/onlineClassroom/study',
        name: 'classroomVideo',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/classroomVideo'
          ),
        meta: {
          topMenu: 'onlineStudy'
        }
      },
      {
        path: '/onlineClassroom/studentInfo',
        name: 'classroomStudentInfo',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/studentInfo/index'
          ),
        meta: {
          topMenu: 'studentInfo'
        }
      },
      {
        path: '/onlineClassroom/myCollection',
        name: 'classroomCollection',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/studyRecord/myCollection'
          ),
        meta: {
          topMenu: 'studyRecord'
        }
      },
      {
        path: '/onlineClassroom/browsingHistory',
        name: 'browsingHistory',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/studyRecord/browsingHistory'
          ),
        meta: {
          topMenu: 'studyRecord'
        }
      },
      // 学习资源
      {
        path: '/onlineClassroom/myUpload',
        name: 'classroomUpload',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/studyResource/myUpload'
          ),
        meta: {
          topMenu: 'studyResource'
        }
      },
      {
        path: '/onlineClassroom/myVideoUpload',
        name: 'classroomVideoUpload',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/studyResource/myVideoUpload'
          ),
        meta: {
          topMenu: 'studyResource'
        }
      },
      {
        path: '/onlineClassroom/updatePassword',
        name: 'classroomVideoUpload',
        component: () =>
          import(
            /* webpackChunkName: "onlineClassroom" */ '@/views/onlineClassroom/views/personCenter/updatePassword'
          ),
        meta: {
          topMenu: 'personCenter'
        }
      }
    ]
  }
]
const createRouter = () =>
  new Router({
    base: process.env.VUE_APP_PUBLIC_PATH || '/',
    mode: process.env.VUE_APP_BUILD_APP === 'true' ? 'hash' : 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: [...constantRoutes, ...customRouter]
  })

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
